<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/commons/taglibs.jsp"%>
<%@ include file="/static/commons/meta.jsp"%>
<%@ include file="/static/commons/jquery-easyui.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 	<title>${title }</title>
	<!--自定义index样式-->
	<link rel="stylesheet" href="${ctx }/static/styles/basic/basic.css" ></link>
	<link rel="stylesheet" href="${ctx }/static/styles/edit/tableStyle.css" ></link>
	<link rel="stylesheet" href="${ctx }/static/scripts/autocomplete/autocomplate.css" ></link>
	<!--js库-->
	<script type="text/javascript" src="${ctx}/static/scripts/set_select.js"></script>
	<script type="text/javascript" src="${ctx}/static/scripts/check_all.js"></script>
	<style type="text/css">
		body{padding: 8px; overflow:hidden;}
		.search_icon{background: url(${ctx}/static/images/head/search.png) no-repeat 1px 50% #c0c0c0;border-radius: 5px;border:1px solid #ccc; width: 20px; height: 20px;cursor: pointer;float:right;margin: 5px 5px 0px 0px}
		.search_icon:HOVER{background-color: #ccc;}
	</style>
	<script type="text/javascript">
		var headers = {};
		headers['__RequestVerificationToken'] = "${RequestVerificationToken}";
	</script>
  </head>
  
  <body>
	<form id="editForm" action="${ctx}/myInspect/save" method="post">
		<input type="hidden" id="equId" name="p_equId" data-field="equ_id" class="echo"></input> 
		<input type="hidden" id="orderId" name="p_orderId" data-field="order_id" class="echo"></input> 
		<input type="hidden" id="logId" name="p_logId" data-field="log_id" class="echo"></input> 
		<input type="hidden" id="ifCert" name="p_ifCert" data-field="if_cert" class="echo"></input>
		<input type="hidden" id="recId" name="p_recId" data-field="rec_id" class="echo"></input>
		<input type="hidden" id="originalRecord" name="p_originalRecord" data-field="original_record" class="echo"></input>
		<table id="tag1" class="table-ltr">
			<tbody>
				<tr>
					<td>送检单位：</td>
					<td><vvise:select id="custId" name="p_custId" sqlname="getCust" defval="${obj.custId }" ifSelect="false" /></td>
					<td>检定日期：</td>
					<td><input type="text" data-field="inspect_date" class="echo" disabled="disabled"></input></td>
					<td>地点：</td>
					<td><input type="text" data-field="address" class="echo" disabled="disabled"></input></td>
				</tr>
				<tr>
					<td class="non-empty">仪器编号：</td>
					<td><input type="text" id="deviceNo" name="p_deviceNo" data-field="device_no" class="echo" autocomplete="off" style="width: 115px" placeholder="模糊搜索"></input>
						<div class="search_icon" title="查询"></div></td>
					<td>类型：</td>
					<td <c:if test="${obj.deviceType eq 2}">colspan="3"</c:if>><vvise:select id="deviceType" name="p_deviceType" sqlname="getCodeData" sqlparam="device_type" defval="${obj.deviceType }" ifSelect="false" /></td>
					<c:if test="${obj.deviceType eq 1}">
						<td>容积：</td>
						<td><input type="text" data-field="volume_category_" class="echo" disabled="disabled"></input></td>
					</c:if>
					<c:if test="${obj.deviceType eq 3}">
						<td>气体种类：</td>
						<td><input type="text" data-field="gas_type_" class="echo" id="gasTypeId" name="p_gasType" readonly></input></td>
					</c:if>
				</tr>
				<tr>
					<td>名称：</td>
					<td><input type="text" data-field="device_name" class="echo" disabled="disabled"></input></td>
					<td>生产厂家：</td>
					<td><input type="text" data-field="device_manufactor" class="echo" disabled="disabled"></input></td>
					<c:if test="${obj.deviceType eq 1}">
						<td>出厂日期：</td>
						<td><input type="text" data-field="manufacture_date" class="echo" disabled="disabled"></input></td>
					</c:if>
					<c:if test="${obj.deviceType ne 1}">
						<td>仪器型号：</td>
						<td><input type="text" data-field="device_model" class="echo" disabled="disabled"></input></td>
					</c:if>
					
					
					
				</tr>
				<tr>
					<td>是否需要证书：</td>
					<td><input type="text" data-field="if_cert_" class="echo" disabled="disabled"></input></td>
					<td>检查人员：</td>
					<td>
						<input type="text" data-field="inspect_user" class="echo" disabled="disabled"></input>
						<input type="hidden" data-field="inspect_user_id" name="p_inspectUser" class="echo" ></input>
					</td>
					<td>核验人员：</td>
					<td>
						<input type="text" data-field="check_user" class="echo" disabled="disabled"></input>
						<input type="hidden" data-field="check_user_id" name="p_checkUser" class="echo" ></input>
					</td>
				</tr>
				<tr>
					<td>检修人员：</td>
					<td>${LoginUser.userName }</td>
					<td>检修日期：</td>
					<td>${inspectDate }</td>
					<td class="non-empty">检修地点：</td>
					<td><input type="text" id="address" name="p_address" data-field="rcl_address" class="echo" ></input></td>
				</tr>
			</tbody>
		</table>
		<table id="tag2" class="table-ltr" style="white-space: nowrap;">
			<caption>检查明细</caption>
			<tbody>
			<!-- <tr>	
					<td>故障现象：</td>
					<td></td>
					<td>更换配件：</td>
					<td></td>
				</tr> -->
			</tbody>
			<tfoot>
				<tr>
					<td style="width:120px;">维修检查人员备注：</td>
					<td colspan="3"><input type="text" data-field="repair_remark" class="echo" disabled="disabled"></input></td>
				</tr>
				<tr>
					<td>核验人员备注：</td>
					<td colspan="3"><input type="text" data-field="check_remark" class="echo" disabled="disabled"></input></td>
				</tr>
				<tr>
					<td class="non-empty">检修备注：</td>
					<td colspan="3"><input type="text" id="remark" name="p_remark" data-field="rcl_remark" class="echo"></input></td>
				</tr>
			</tfoot>
		</table>
		</div>
		<div name="ysjld" id="ysjld">

		</div>
	</form>
</body>
<script type="text/javascript">
	var validForm;
    $(function(){
    	
    	/* 1. 检索待检设备信息 */
    	$(document).delegate('.search_icon', 'click', function(){
    		var pp = parent;
    		var editFrame = pp.winFrame;
    		if(!pp.validData("deviceNo","请输入仪器编号！", 1, editFrame))
				return;
    		
    		var deviceNo = editFrame.$('#deviceNo').val();
    		var result = pp.executeAjaxBySync('${ctx}/myRepair/getEquipment','p_deviceType=${obj.deviceType}&p_custId=${obj.custId}&p_deviceNo='+deviceNo);
			if(result == 'none'){
			 	pp.$.messager.alert('操作提示','未查询到待检设备，请重新输入','warning',function(){
				 	editFrame.$('#deviceNo').focus();
			 	});
				return;
			}else{
				/* console.log(result) */
				var data = eval("("+result+")");
				var equ = data.columns;
				var recId = equ.rec_id;
//				if(!pp.isEmpty(recId)){
//					pp.$.messager.alert('操作提示','该设备已检测，请重新输入','warning',function(){
//					 	editFrame.$('#deviceNo').focus();
//				 	});
//					return;
//				}
				
				$('.echo').each(function(){
					var field = $(this).data('field');
					var val = eval('equ.'+field);
					if(!val){
						val = ''
					}
					$(this).val(val);
				});
				
				var ifCert = equ.if_cert;
				if(ifCert==1){
					pp.$('#winDiv #btn0').hide();
					pp.$('#winDiv #btn1').show();
				}else{
					pp.$('#winDiv #btn0').show();
					pp.$('#winDiv #btn1').hide();
				}
				
	        	var tbody = $('#tag2').find('tbody');
				var trs = "";
				var details = pp.executeAjaxBySync('${ctx}/myRepair/getEquipment','queryType=1&equId='+$('#equId').val());
				var data1 = eval("("+details+")");
				if(data1){
					for(var i=0; i<data1.length; i++){
						trs += "<tr>\n" +
								"<td>故障现象：</td>\n" + 
								"<td>"+data1[i][1]+"</td>\n" + 
								"<td>更换配件：</td>\n" + 
								"<td>"+data1[i][2]+"</td>\n" + 
								"</tr>";
					}
				}
				tbody.html(trs);
			}
		});
    	
    	
    	/* 2. 表单非空验证 */
    	validForm = function(){
    		var pp = parent;
    		var editFrame = pp.winFrame;
    		if(!pp.validData("deviceNo","请输入仪器编号！", 1, editFrame))
    			return false;
    		if(!pp.validData("address","请输入检修地点！", 1, editFrame))
				return false;
    		if(!pp.validData("remark","请输入检修备注！", 1, editFrame))
				return false;
    		return true;
    	};
    	
        //自动填充车牌数组
        var result = '${data}';
        var data = jQuery.parseJSON(result);
        $('#deviceNo').autocomplete(data, {
            max: 7, //列表里的条目数                 
            minChars: 1, //自动完成激活之前填入的最小字符                  
            width: 150, //提示的宽度，溢出隐藏                 
            scrollHeight: 180, //提示的高度，溢出显示滚动条     
            matchCase: false, //比较是否开启大小写敏感开关             
            matchContains: true, //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示                  
            autoFill: false, //自动填充                  //匹配的项所要发生的事件                 
            formatItem: function (row, i, max){
               //row表示每一行的数据对象，i表示每一行的编号 max表示总的数据行数                     
                return row.value + "[" + row.name + "]";
            }
        }).result(function (event, row, formatted) {
            $('#deviceNo').val(row.value);
        });
    });
   </script>
<script type="text/javascript" src="${ctx}/static/scripts/autocomplete/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="${ctx}/static/scripts/autocomplete/jquery.autocomplete.js"></script>
</html>